//将来整个项目接口都在这里书写统一管理
//项目任何地方发请求:必然会用到二次封装axios
import requests from "@/utils/request"; //获取学校真实服务器axios

//获取用户信息的请求
export const reqUserInfo = () => requests({ url: "/api/user/passport/auth/getUserInfo", method: "get" });
//注册用户的接口
export const reqRegister = (data) => requests({ url: `/api/user/passport/register`, method: "post", data });
//登录接口
export const reqLogin = (data) => requests({ url: `/api/user/passport/login`, method: "post", data });
//退出登录
export const reqLogOut = () => requests({ url: `/api/user/passport/logout`, method: "get" });
//获取验证码
export const reqGetCode = (phone) => requests({ url: `/api/user/passport/sendCode/${phone}`, method: "get" });
// 请求一级分类的数据
export const reqCateList = (id) =>
  requests({ url: `/wy/item/cateList.json?__timestamp=1630131455012&categoryId=${id}`, method: "get" });
// 请求二级分类的数据
export const reqCateGroupDate = (categoryId = 11, subCategoryId) =>
  requests({ url: `/wy/item/list.json?__timestamp=1630133942864&categoryType=0&categoryId=${categoryId}&subCategoryId=${subCategoryId}`, method: "get" });
// 获取热门关键字
export const getKeyValue = () => requests({ url: "/wy/xhr/search/init.json", method: "get" });
// 实时关键字列表
export const getSearch = (keywordPrefix) => requests({
  url: `/wy/xhr/search/searchAutoComplete.json?keywordPrefix=${keywordPrefix}`,
  headers: {
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
  },
  method: "get"
})

//获取首页数据
export const reqHomeData = () => requests({ url: "/wy/xhr/index.json", method: "get" });
//获取分类的列表
export const reqNavList = () => requests({ url: "/wy/item/cateList.json", method: "get" });
// 获取分类下的商品列表
export const reqGoodsList = (categoryId) => requests({ url: `/wy/item/list.json?timestamp=1630133942864&categoryId=${categoryId}`, method: "get" });

